home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume14 / flex / part01 next >
Encoding:
Internet Message Format  |  1988-05-02  |  53.5 KB

  1. Subject:  v14i079:  Flex, a lex replacement, Part01/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Vern Paxson <vern@lbl-csam.arpa>
  7. Posting-number: Volume 14, Issue 79
  8. Archive-name: flex/part01
  9.  
  10. This is the initial release of flex, a replacement for the lex(1) tool.
  11. As the copyright indicates, this distribution can be freely
  12. redistributed.
  13.  
  14. Yes, there are some niggling lex features which are not available which
  15. seem like they'd be easy to add.  They're not, or if they are then the
  16. straight-forward implementation of them would slow down the scanner.
  17. Unfortunately I am unable to do any further work on flex other than bug
  18. fixes, so if there's something you've just gotta have, you'd better be
  19. willing to dive into the code.  I'll be happy to give (fairly high-level)
  20. advice on how to proceed.
  21.  
  22. Flex runs on Sun and 4.3 Unix.  For a System V machine, add the #define
  23. "SV".  Not guaranteed to do the full job, but a step in the right
  24. direction.  Work is being done on an MS-DOS port.
  25.  
  26. For more details on the installation, see the README.
  27.  
  28. Please send problems and feedback to:
  29.  
  30.     vern@lbl-{csam,rtsg}.arpa  or  ucbvax!lbl-csam.arpa!vern
  31.  
  32.     Vern Paxson
  33.     Real Time Systems Group
  34.     Bldg. 46A
  35.     Lawrence Berkeley Laboratory
  36.     1 Cyclotron Rd.
  37.     Berkeley, CA 94720
  38.  
  39.     (415) 486-6411
  40.  
  41. #! /bin/sh
  42. # This is a shell archive.  Remove anything before this line, then unpack
  43. # it by saving it into a file and typing "sh file".  To overwrite existing
  44. # files, type "sh file -c".  You can also feed this as standard input via
  45. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  46. # will see the following message at the end:
  47. #        "End of archive 1 (of 5)."
  48. # Contents:  Changes MANIFEST Makefile README Timings ccl.c ecs.c
  49. #   fastskeldef.h flex.skel flexskelcom.h flexskeldef.h parse.y sym.c
  50. #   yylex.c
  51. # Wrapped by rsalz@fig.bbn.com on Tue May  3 17:31:25 1988
  52. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  53. if test -f 'Changes' -a "${1}" != "-c" ; then 
  54.   echo shar: Will not clobber existing file \"'Changes'\"
  55. else
  56. echo shar: Extracting \"'Changes'\" \(861 characters\)
  57. sed "s/^X//" >'Changes' <<'END_OF_FILE'
  58. Changes between beta-test release of Feb. '88 and initial release:
  59. X
  60. X    - many files renamed to remove "flex" prefix
  61. X    - input() routine added to compressed and fast skeletons
  62. X    - unput() routine added to compressed skeleton
  63. X    - -d, -ce support for fast scanners
  64. X    - symbol table extended to avoid ugly casts of ints <-> char *'s;
  65. X      this may relieve MS-DOS woes
  66. X    - actions are now separated with YY_BREAK instead of simple "break"'s
  67. X    - fixed bug causing core-dumps if skeleton file could not be opened
  68. X    - fixed bugs in logic deciding which options cannot be intermixed
  69. X    - initial start condition can now be referred to as <INITIAL>
  70. X    - fixed bug which would incorrectly computer trailing context
  71. X      count for a pattern like "(foo){3}"; now this is considered
  72. X      "variable length", even though it isn't.
  73. X    - block comments allowed between rules
  74. X    - misc. typos corrected
  75. END_OF_FILE
  76. if test 861 -ne `wc -c <'Changes'`; then
  77.     echo shar: \"'Changes'\" unpacked with wrong size!
  78. fi
  79. # end of 'Changes'
  80. fi
  81. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  82.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  83. else
  84. echo shar: Extracting \"'MANIFEST'\" \(858 characters\)
  85. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  86. X   File Name        Archive #    Description
  87. X-----------------------------------------------------------
  88. X Changes                    1    
  89. X MANIFEST                   1    This shipping list
  90. X Makefile                   1    
  91. X README                     1    
  92. X Timings                    1    
  93. X ccl.c                      1    
  94. X dfa.c                      2    
  95. X ecs.c                      1    
  96. X fastskeldef.h              1    
  97. X flex.1                     3    
  98. X flex.fastskel              2    
  99. X flex.skel                  1    
  100. X flexdef.h                  3    
  101. X flexskelcom.h              1    
  102. X flexskeldef.h              1    
  103. X main.c                     2    
  104. X misc.c                     2    
  105. X nfa.c                      3    
  106. X parse.y                    1    
  107. X scan.c.dist                4    
  108. X scan.l                     2    
  109. X sym.c                      1    
  110. X tblcmp.c                   5    
  111. X yylex.c                    1    
  112. END_OF_FILE
  113. if test 858 -ne `wc -c <'MANIFEST'`; then
  114.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  115. fi
  116. # end of 'MANIFEST'
  117. fi
  118. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  119.   echo shar: Will not clobber existing file \"'Makefile'\"
  120. else
  121. echo shar: Extracting \"'Makefile'\" \(1264 characters\)
  122. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  123. X# make file for "flex" tool
  124. X
  125. X# the first time around use "make first_flex"
  126. X
  127. SKELETON_FILE = \"/usr/local/lib/flex.skel\"
  128. XF_SKELETON_FILE = \"/usr/local/lib/flex.fastskel\"
  129. SKELFLAGS = -DDEFAULT_SKELETON_FILE=$(SKELETON_FILE) \
  130. X        -DFAST_SKELETON_FILE=$(F_SKELETON_FILE)
  131. CFLAGS = -O
  132. LDFLAGS =
  133. X
  134. XFLEX_FLAGS = -ist
  135. XFLEX = flex
  136. X
  137. XFLEXOBJS = \
  138. X    ccl.o \
  139. X    dfa.o \
  140. X    ecs.o \
  141. X    main.o \
  142. X    misc.o \
  143. X    nfa.o \
  144. X    parse.o \
  145. X    scan.o \
  146. X    sym.o \
  147. X    tblcmp.o \
  148. X    yylex.o
  149. X
  150. XFLEX_C_SOURCES = \
  151. X    ccl.c \
  152. X    dfa.c \
  153. X    ecs.c \
  154. X    main.c \
  155. X    misc.c \
  156. X    nfa.c \
  157. X    parse.c \
  158. X    scan.c \
  159. X    sym.c \
  160. X    tblcmp.c \
  161. X    yylex.c
  162. X
  163. flex : $(FLEXOBJS)
  164. X    cc $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
  165. X
  166. first_flex:
  167. X    cp scan.c.dist scan.c
  168. X    make $(MFLAGS) flex
  169. X
  170. parse.h parse.c : parse.y
  171. X    yacc -d parse.y
  172. X    @mv y.tab.c parse.c
  173. X    @mv y.tab.h parse.h
  174. X
  175. X# comment-out the next two lines after a successful "make test" and
  176. X# comment-in the following two lines.
  177. X
  178. scan.c : scan.l
  179. X    $(FLEX) $(FLEX_FLAGS) scan.l >scan.c
  180. X
  181. scan.o : scan.c parse.h
  182. X
  183. main.o : main.c
  184. X    cc $(CFLAGS) -c $(SKELFLAGS) main.c
  185. X
  186. flex.lint : $(FLEX_C_SOURCES)
  187. X    @echo "Expect a \"may be used before set\" and 2 \"unused\"'s
  188. X    lint $(FLEX_C_SOURCES) > flex.lint
  189. X
  190. clean :
  191. X    rm -f core errs flex *.o parse.c *.lint parse.h
  192. X
  193. test :
  194. X    $(FLEX) $(FLEX_FLAGS) scan.l | diff scan.c -
  195. END_OF_FILE
  196. if test 1264 -ne `wc -c <'Makefile'`; then
  197.     echo shar: \"'Makefile'\" unpacked with wrong size!
  198. fi
  199. # end of 'Makefile'
  200. fi
  201. if test -f 'README' -a "${1}" != "-c" ; then 
  202.   echo shar: Will not clobber existing file \"'README'\"
  203. else
  204. echo shar: Extracting \"'README'\" \(3402 characters\)
  205. sed "s/^X//" >'README' <<'END_OF_FILE'
  206. This is the initial release of flex, a replacement for the lex(1)
  207. tool.  As the copyright indicates, this distribution can be freely
  208. redistributed.
  209. X
  210. Some notes on the distribution:
  211. X
  212. X    Yes, there are some niggling lex features which are not available which
  213. X    seem like they'd be easy to add.  They're not, or if they are then the
  214. X    straight-forward implementation of them would slow down the scanner.
  215. X    Unfortunately I am unable to do any further work on flex other than bug
  216. X    fixes, so if there's something you've just gotta have, you'd better
  217. X    be willing to dive into the code.  I'll be happy to give (fairly
  218. X    high-level) advice on how to proceed.
  219. X
  220. X    The compressed tables have been tested pretty thoroughly in the past,
  221. X    though may be suffering from bit-rot.  The fast/full tables have been
  222. X    recently implemented and are more likely to have bugs.
  223. X
  224. X    For a System V machine, add the #define "SV".  Not guaranteed to do
  225. X    the full job, but a step in the right direction.
  226. X
  227. X    Flex has been successfully ported to Sun Unix and 4.3BSD Vax Unix.
  228. X
  229. X
  230. The flex distribution consists of the following files:
  231. X
  232. X    README        This message
  233. X
  234. X    Changes        Differences between this release and the beta-test
  235. X
  236. X    Makefile
  237. X    flexdef.h
  238. X    parse.y
  239. X    scan.l
  240. X    ccl.c
  241. X    dfa.c        flex sources
  242. X    ecs.c
  243. X    main.c
  244. X    misc.c
  245. X    nfa.c
  246. X    sym.c
  247. X    tblcmp.c
  248. X    yylex.c
  249. X
  250. X    scan.c.dist    pre-flex'd version of scan.l
  251. X
  252. X    flex.skel
  253. X    flex.fastskel
  254. X    flexskelcom.h    skeleton scanner sources
  255. X    flexskeldef.h
  256. X    fastskeldef.h
  257. X
  258. X    flex.1        manual entry
  259. X
  260. X    Timings        a brief note comparing timings of flex vs. lex
  261. X
  262. X[  The following section is only true if you got the files from FTP
  263. X    to LBL, directly, and not from the more widely-distributed
  264. X    comp.sources.unix publication.  --Rich $alz
  265. The files are packaged as a compressed shell archive, which in turn
  266. contains seven shell archives.  Create a directory where you want flex
  267. to live, cd there, and use
  268. X
  269. X    uncompress flex.shar.Z
  270. X    sh flex.shar
  271. X
  272. X    sh flex.shar.1
  273. X    sh flex.shar.2
  274. X    sh flex.shar.3
  275. X    sh flex.shar.4
  276. X    sh flex.shar.5
  277. X    sh flex.shar.6
  278. X    sh flex.shar.7
  279. X
  280. to extract them.
  281. X]
  282. X
  283. Either move {flexskelcom.h,flexskeldef.h,fastskeldef.h} into /usr/include
  284. or edit {flex.skel,flex.fastskel,flexskeldef.h,fastskeldef.h,scan.c.dist}
  285. and wire in the full pathname of where you are going to keep the include files.
  286. X
  287. Decide where you want to keep {flex.skel,flex.fastskel} (suggestion:
  288. X/usr/local/lib) and move it there.  Edit "Makefile" and change the
  289. definitions of SKELETON_FILE and F_SKELETON_FILE to reflect the full
  290. pathnames of {flex.skel,flex.fastskel}.
  291. X
  292. To make flex for the first time, use:
  293. X
  294. X    make first_flex
  295. X
  296. which uses a pre-generated copy of the scanner whose source is in flex.
  297. X
  298. Assuming it builds successfully, you can test it using
  299. X
  300. X    make test
  301. X
  302. The "diff" should not show any differences.
  303. X
  304. If you're feeling adventurous, rebuild scan.c using various
  305. combinations of FLEX_FLAGS, each time trying "make test" when
  306. you're done.  To rebuild it, do
  307. X
  308. X    rm scan.c
  309. X    make FLEX_FLAGS="..."
  310. X
  311. where "..." is one of:
  312. X
  313. X    -ist -c
  314. X    -ist -ce
  315. X    -ist -cm
  316. X    -ist -cfe
  317. X    -ist -cFe
  318. X
  319. and testing using:
  320. X
  321. X    make FLEX_FLAGS="..." test
  322. X
  323. X
  324. XFormat the manual entry using
  325. X
  326. X    nroff -man flex.1
  327. X
  328. X
  329. Please send problems and feedback to:
  330. X
  331. X    vern@lbl-{csam,rtsg}.arpa  or  ucbvax!lbl-csam.arpa!vern
  332. X
  333. X    Vern Paxson
  334. X    Real Time Systems Group
  335. X    Bldg. 46A
  336. X    Lawrence Berkeley Laboratory
  337. X    1 Cyclotron Rd.
  338. X    Berkeley, CA 94720
  339. X
  340. X    (415) 486-6411
  341. END_OF_FILE
  342. if test 3402 -ne `wc -c <'README'`; then
  343.     echo shar: \"'README'\" unpacked with wrong size!
  344. fi
  345. # end of 'README'
  346. fi
  347. if test -f 'Timings' -a "${1}" != "-c" ; then 
  348.   echo shar: Will not clobber existing file \"'Timings'\"
  349. else
  350. echo shar: Extracting \"'Timings'\" \(857 characters\)
  351. sed "s/^X//" >'Timings' <<'END_OF_FILE'
  352. flex vs. lex timings for a C tokenizer which includes keywords:
  353. X
  354. Generation times:
  355. X
  356. X    lex        83.0 secs
  357. X    flex         3.9
  358. X    flex -cfe    7.1    # uncompressed table, equivalence classes
  359. X    flex -cf    15.0    # uncompressed table, no equivalence classes
  360. X
  361. Scanner object file sizes:
  362. X
  363. X    lex       41.0K bytes
  364. X    flex        9.4K
  365. X    flex -cfe  49.6K
  366. X    flex -cf  126.5K
  367. X
  368. Running times on a 28,088 line input (685K characters):
  369. X
  370. X    lex       29.8 secs
  371. X    flex       19.3
  372. X    flex -cfe   9.0
  373. X    flex -cf    7.8
  374. X
  375. The timings were made on a Sun 3/60.  All times are user + system CPU time,
  376. and don't include hashing of identifiers.
  377. X
  378. Summary:
  379. X
  380. X    For about the same sized scanner, you get a factor of 3 in performance.
  381. X    For a 30% faster scanner, you get a scanner 1/4th the size, and it's
  382. X    generated in 1/20th the time.
  383. X    For a scanner that's 3 times larger, you get a factor of 3.8 in
  384. X    performance.
  385. END_OF_FILE
  386. if test 857 -ne `wc -c <'Timings'`; then
  387.     echo shar: \"'Timings'\" unpacked with wrong size!
  388. fi
  389. # end of 'Timings'
  390. fi
  391. if test -f 'ccl.c' -a "${1}" != "-c" ; then 
  392.   echo shar: Will not clobber existing file \"'ccl.c'\"
  393. else
  394. echo shar: Extracting \"'ccl.c'\" \(2257 characters\)
  395. sed "s/^X//" >'ccl.c' <<'END_OF_FILE'
  396. X/* ccl - routines for character classes */
  397. X
  398. X/*
  399. X * Copyright (c) 1987, the University of California
  400. X * 
  401. X * The United States Government has rights in this work pursuant to
  402. X * contract no. DE-AC03-76SF00098 between the United States Department of
  403. X * Energy and the University of California.
  404. X * 
  405. X * This program may be redistributed.  Enhancements and derivative works
  406. X * may be created provided the new works, if made available to the general
  407. X * public, are made available for use by anyone.
  408. X */
  409. X
  410. X#include "flexdef.h"
  411. X
  412. X/* ccladd - add a single character to a ccl
  413. X *
  414. X * synopsis
  415. X *    int cclp;
  416. X *    char ch;
  417. X *    ccladd( cclp, ch );
  418. X */
  419. X
  420. ccladd( cclp, ch )
  421. int cclp;
  422. char ch;
  423. X
  424. X    {
  425. X    int ind, len, newpos, i;
  426. X
  427. X    len = ccllen[cclp];
  428. X    ind = cclmap[cclp];
  429. X
  430. X    /* check to see if the character is already in the ccl */
  431. X
  432. X    for ( i = 0; i < len; ++i )
  433. X    if ( ccltbl[ind + i] == ch )
  434. X        return;
  435. X
  436. X    newpos = ind + len;
  437. X
  438. X    if ( newpos >= current_max_ccl_tbl_size )
  439. X    {
  440. X    current_max_ccl_tbl_size += MAX_CCL_TBL_SIZE_INCREMENT;
  441. X
  442. X    ++num_reallocs;
  443. X
  444. X    ccltbl = reallocate_character_array( ccltbl, current_max_ccl_tbl_size );
  445. X    }
  446. X
  447. X    ccllen[cclp] = len + 1;
  448. X    ccltbl[newpos] = ch;
  449. X    }
  450. X
  451. X
  452. X/* cclinit - make an empty ccl
  453. X *
  454. X * synopsis
  455. X *    int cclinit();
  456. X *    new_ccl = cclinit();
  457. X */
  458. X
  459. int cclinit()
  460. X
  461. X    {
  462. X    if ( ++lastccl >= current_maxccls )
  463. X    {
  464. X    current_maxccls += MAXCCLS_INCREMENT;
  465. X
  466. X    ++num_reallocs;
  467. X
  468. X    cclmap = reallocate_integer_array( cclmap, current_maxccls );
  469. X    ccllen = reallocate_integer_array( ccllen, current_maxccls );
  470. X    cclng = reallocate_integer_array( cclng, current_maxccls );
  471. X    }
  472. X
  473. X    if ( lastccl == 1 )
  474. X    /* we're making the first ccl */
  475. X    cclmap[lastccl] = 0;
  476. X
  477. X    else
  478. X    /* the new pointer is just past the end of the last ccl.  Since
  479. X     * the cclmap points to the \first/ character of a ccl, adding the
  480. X     * length of the ccl to the cclmap pointer will produce a cursor
  481. X     * to the first free space
  482. X     */
  483. X    cclmap[lastccl] = cclmap[lastccl - 1] + ccllen[lastccl - 1];
  484. X
  485. X    ccllen[lastccl] = 0;
  486. X    cclng[lastccl] = 0;    /* ccl's start out life un-negated */
  487. X
  488. X    return ( lastccl );
  489. X    }
  490. X
  491. X
  492. X/* cclnegate - negate a ccl
  493. X *
  494. X * synopsis
  495. X *    int cclp;
  496. X *    cclnegate( ccl );
  497. X */
  498. X
  499. cclnegate( cclp )
  500. int cclp;
  501. X
  502. X    {
  503. X    cclng[cclp] = 1;
  504. X    }
  505. END_OF_FILE
  506. if test 2257 -ne `wc -c <'ccl.c'`; then
  507.     echo shar: \"'ccl.c'\" unpacked with wrong size!
  508. fi
  509. # end of 'ccl.c'
  510. fi
  511. if test -f 'ecs.c' -a "${1}" != "-c" ; then 
  512.   echo shar: Will not clobber existing file \"'ecs.c'\"
  513. else
  514. echo shar: Extracting \"'ecs.c'\" \(4546 characters\)
  515. sed "s/^X//" >'ecs.c' <<'END_OF_FILE'
  516. X/* ecs - equivalence class routines */
  517. X
  518. X/*
  519. X * Copyright (c) 1987, the University of California
  520. X * 
  521. X * The United States Government has rights in this work pursuant to
  522. X * contract no. DE-AC03-76SF00098 between the United States Department of
  523. X * Energy and the University of California.
  524. X * 
  525. X * This program may be redistributed.  Enhancements and derivative works
  526. X * may be created provided the new works, if made available to the general
  527. X * public, are made available for use by anyone.
  528. X */
  529. X
  530. X#include "flexdef.h"
  531. X
  532. X/* ccl2ecl - convert character classes to set of equivalence classes
  533. X *
  534. X * synopsis
  535. X *    ccl2ecl();
  536. X */
  537. X
  538. ccl2ecl()
  539. X
  540. X    {
  541. X    int i, ich, newlen, cclp, ccls, cclmec;
  542. X
  543. X    for ( i = 1; i <= lastccl; ++i )
  544. X    {
  545. X    /* we loop through each character class, and for each character
  546. X     * in the class, add the character's equivalence class to the
  547. X     * new "character" class we are creating.  Thus when we are all
  548. X     * done, character classes will really consist of collections
  549. X     * of equivalence classes
  550. X     */
  551. X
  552. X    newlen = 0;
  553. X    cclp = cclmap[i];
  554. X
  555. X    for ( ccls = 0; ccls < ccllen[i]; ++ccls )
  556. X        {
  557. X        ich = ccltbl[cclp + ccls];
  558. X        cclmec = ecgroup[ich];
  559. X        if ( cclmec > 0 )
  560. X        {
  561. X        ccltbl[cclp + newlen] = cclmec;
  562. X        ++newlen;
  563. X        }
  564. X        }
  565. X
  566. X    ccllen[i] = newlen;
  567. X    }
  568. X    }
  569. X
  570. X
  571. X/* cre8ecs - associate equivalence class numbers with class members
  572. X *
  573. X * synopsis
  574. X *    int cre8ecs();
  575. X *    number of classes = cre8ecs( fwd, bck, num );
  576. X *
  577. X *  fwd is the forward linked-list of equivalence class members.  bck
  578. X *  is the backward linked-list, and num is the number of class members.
  579. X *  Returned is the number of classes.
  580. X */
  581. X
  582. int cre8ecs( fwd, bck, num )
  583. int fwd[], bck[], num;
  584. X
  585. X    {
  586. X    int i, j, numcl;
  587. X
  588. X    numcl = 0;
  589. X
  590. X    /* create equivalence class numbers.  From now on, abs( bck(x) )
  591. X     * is the equivalence class number for object x.  If bck(x)
  592. X     * is positive, then x is the representative of its equivalence
  593. X     * class.
  594. X     */
  595. X
  596. X    for ( i = 1; i <= num; ++i )
  597. X    if ( bck[i] == NIL )
  598. X        {
  599. X        bck[i] = ++numcl;
  600. X        for ( j = fwd[i]; j != NIL; j = fwd[j] )
  601. X        bck[j] = -numcl;
  602. X        }
  603. X
  604. X    return ( numcl );
  605. X    }
  606. X
  607. X
  608. X/* mkeccl - update equivalence classes based on character class xtions
  609. X *
  610. X * synopsis
  611. X *    char ccls[];
  612. X *    int lenccl, fwd[llsiz], bck[llsiz], llsiz;
  613. X *    mkeccl( ccls, lenccl, fwd, bck, llsiz );
  614. X *
  615. X * where ccls contains the elements of the character class, lenccl is the
  616. X * number of elements in the ccl, fwd is the forward link-list of equivalent
  617. X * characters, bck is the backward link-list, and llsiz size of the link-list
  618. X */
  619. X
  620. mkeccl( ccls, lenccl, fwd, bck, llsiz )
  621. char ccls[];
  622. int lenccl, fwd[], bck[], llsiz;
  623. X
  624. X    {
  625. X    int cclp, oldec, newec;
  626. X    int cclm, i, j;
  627. X
  628. X    /* note that it doesn't matter whether or not the character class is
  629. X     * negated.  The same results will be obtained in either case.
  630. X     */
  631. X
  632. X    cclp = 0;
  633. X
  634. X    while ( cclp < lenccl )
  635. X    {
  636. X    cclm = ccls[cclp];
  637. X    oldec = bck[cclm];
  638. X    newec = cclm;
  639. X
  640. X    j = cclp + 1;
  641. X
  642. X    for ( i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i] )
  643. X        { /* look for the symbol in the character class */
  644. X        for ( ; j < lenccl && ccls[j] <= i; ++j )
  645. X        if ( ccls[j] == i )
  646. X            {
  647. X            /* we found an old companion of cclm in the ccl.
  648. X             * link it into the new equivalence class and flag it as
  649. X             * having been processed
  650. X             */
  651. X
  652. X            bck[i] = newec;
  653. X            fwd[newec] = i;
  654. X            newec = i;
  655. X            ccls[j] = -i;    /* set flag so we don't reprocess */
  656. X
  657. X            /* get next equivalence class member */
  658. X            /* next 2 */ goto next_pt;
  659. X            }
  660. X
  661. X        /* symbol isn't in character class.  Put it in the old equivalence
  662. X         * class
  663. X         */
  664. X
  665. X        bck[i] = oldec;
  666. X
  667. X        if ( oldec != NIL )
  668. X        fwd[oldec] = i;
  669. X
  670. X        oldec = i;
  671. next_pt:
  672. X        ;
  673. X        }
  674. X
  675. X    if ( bck[cclm] != NIL || oldec != bck[cclm] )
  676. X        {
  677. X        bck[cclm] = NIL;
  678. X        fwd[oldec] = NIL;
  679. X        }
  680. X
  681. X    fwd[newec] = NIL;
  682. X
  683. X    /* find next ccl member to process */
  684. X
  685. X    for ( ++cclp; ccls[cclp] < 0 && cclp < lenccl; ++cclp )
  686. X        {
  687. X        /* reset "doesn't need processing" flag */
  688. X        ccls[cclp] = -ccls[cclp];
  689. X        }
  690. X    }
  691. X    }
  692. X
  693. X
  694. X/* mkechar - create equivalence class for single character
  695. X *
  696. X * synopsis
  697. X *    int tch, fwd[], bck[];
  698. X *    mkechar( tch, fwd, bck );
  699. X */
  700. X
  701. mkechar( tch, fwd, bck )
  702. int tch, fwd[], bck[];
  703. X
  704. X    {
  705. X    /* if until now the character has been a proper subset of
  706. X     * an equivalence class, break it away to create a new ec
  707. X     */
  708. X
  709. X    if ( fwd[tch] != NIL )
  710. X    bck[fwd[tch]] = bck[tch];
  711. X
  712. X    if ( bck[tch] != NIL )
  713. X    fwd[bck[tch]] = fwd[tch];
  714. X
  715. X    fwd[tch] = NIL;
  716. X    bck[tch] = NIL;
  717. X    }
  718. END_OF_FILE
  719. if test 4546 -ne `wc -c <'ecs.c'`; then
  720.     echo shar: \"'ecs.c'\" unpacked with wrong size!
  721. fi
  722. # end of 'ecs.c'
  723. fi
  724. if test -f 'fastskeldef.h' -a "${1}" != "-c" ; then 
  725.   echo shar: Will not clobber existing file \"'fastskeldef.h'\"
  726. else
  727. echo shar: Extracting \"'fastskeldef.h'\" \(2842 characters\)
  728. sed "s/^X//" >'fastskeldef.h' <<'END_OF_FILE'
  729. X/*  macro definitions for fast/full-table  C/FTL programs generated by flex */
  730. X
  731. X#include "flexskelcom.h"
  732. X
  733. X#define YY_END_OF_BUFFER_CHAR 0
  734. X
  735. X/* action number for "not an accepting state; back-track (not implemented)" */
  736. X#define YY_BACK_TRACK 0
  737. X
  738. X/* action number for end-of-buffer was seen */
  739. X#define YY_END_OF_BUFFER -3
  740. X
  741. X/* reinitializes everything except the current start condition.  The last
  742. X * input character is set to a newline so an initial beginning-of-line
  743. X * rule will match
  744. X */
  745. X#define YY_FAST_INIT \
  746. X    { \
  747. X    yytext = yy_c_buf_p = &yy_ch_buf[1]; \
  748. X    yyleng = 0; \
  749. X    yy_hold_char = *yy_c_buf_p; \
  750. X    }
  751. X
  752. X/* done before the next pattern has been matched action
  753. X * change both of these if you change them at all!
  754. X */
  755. X#define YY_DO_BEFORE_SCAN \
  756. X    *yy_c_buf_p = yy_hold_char
  757. X#define YY_DO_BEFORE_RESTART \
  758. X    yy_hold_char = *yy_c_buf_p
  759. X
  760. X/* done after the current pattern has been matched and before the
  761. X * corresponding action
  762. X */
  763. X#define YY_DO_BEFORE_ACTION \
  764. X    yytext = yy_b_buf_p; \
  765. X    yyleng = YY_LENG; \
  766. X    yy_hold_char = *yy_c_buf_p; \
  767. X    *yy_c_buf_p = '\0'
  768. X
  769. X/* returns the length of the matched text */
  770. X#define YY_LENG (yy_c_buf_p - yy_b_buf_p)
  771. X
  772. X#ifdef FLEX_FULL_TABLE
  773. X#define YY_CS_TYPE int
  774. X#else
  775. X#define YY_CS_TYPE struct yy_trans_info *
  776. X#endif
  777. X
  778. X/* find starting state */
  779. X#ifdef FLEX_FULL_TABLE
  780. X#    define YY_FIND_START_STATE( x ) \
  781. X        x = yy_start; \
  782. X        if ( yy_b_buf_p[-1] == '\n' ) \
  783. X        ++x
  784. X#else
  785. X#    define YY_FIND_START_STATE( x ) \
  786. X        x = yy_state_ptr[yy_start]; \
  787. X        if ( yy_b_buf_p[-1] == '\n' ) \
  788. X        x = yy_state_ptr[yy_start + 1]
  789. X#endif
  790. X
  791. X# ifdef FLEX_USE_ECS
  792. X#     define yy_eq(x) e[x]
  793. X# else
  794. X#     define yy_eq(x) x
  795. X# endif
  796. X
  797. X/* get next jam state from packed table */
  798. X#ifdef FLEX_FULL_TABLE
  799. X#    define YY_FIND_NEXT_MATCH \
  800. X        { \
  801. X        register int yy_state_info; \
  802. X        while ( (yy_state_info = n[yy_current_state][yy_eq(*yy_c_buf_p)] ) != YY_JAM ) \
  803. X        { \
  804. X        yy_current_state = yy_state_info; \
  805. X        YY_BACKTRACKING_ACTION \
  806. X        yy_c_buf_p++; \
  807. X        } \
  808. X        }
  809. X#else
  810. X#    define YY_FIND_NEXT_MATCH \
  811. X        for ( yy_c = yy_eq(*yy_c_buf_p); \
  812. X          (yy_trans_info = &yy_current_state[yy_c])->v == yy_c; \
  813. X          yy_c = yy_eq(*++yy_c_buf_p) ) \
  814. X        { \
  815. X        yy_current_state += yy_trans_info->n; \
  816. X        YY_BACKTRACKING_ACTION \
  817. X        }
  818. X#endif
  819. X
  820. X#ifdef FLEX_FULL_TABLE
  821. X#    define YY_FIND_ACTION( x ) x = l[yy_current_state]
  822. X#else
  823. X#    define YY_FIND_ACTION( x ) x = yy_current_state[-1].n
  824. X#endif
  825. X
  826. X
  827. X#ifdef FLEX_FULL_TABLE
  828. X#    define YY_GET_NEXT_STATE yy_cur_state = n[yy_cur_state][*(yy_temp_char_ptr++)]
  829. X#else
  830. X#    define YY_GET_NEXT_STATE yy_cur_state += yy_cur_state[*(yy_temp_char_ptr++)].n
  831. X#endif
  832. X
  833. X#define EOB_ACT_RESTART_SCAN 2
  834. X#define EOB_ACT_END_OF_FILE 3
  835. X#define EOB_ACT_LAST_MATCH 4
  836. X
  837. X#ifdef FLEX_FULL_TABLE
  838. X#define YY_DECLARE_YY_CS_PARAM int *yy_current_state
  839. X#else
  840. X#define YY_DECLARE_YY_CS_PARAM struct yy_trans_info *yy_current_state
  841. X#endif
  842. END_OF_FILE
  843. if test 2842 -ne `wc -c <'fastskeldef.h'`; then
  844.     echo shar: \"'fastskeldef.h'\" unpacked with wrong size!
  845. fi
  846. # end of 'fastskeldef.h'
  847. fi
  848. if test -f 'flex.skel' -a "${1}" != "-c" ; then 
  849.   echo shar: Will not clobber existing file \"'flex.skel'\"
  850. else
  851. echo shar: Extracting \"'flex.skel'\" \(6545 characters\)
  852. sed "s/^X//" >'flex.skel' <<'END_OF_FILE'
  853. X/* A lexical scanner generated by flex */
  854. X
  855. X#include "flexskeldef.h"
  856. X
  857. X%% section 1 code and data tables for DFA go here
  858. X
  859. X/* these declarations have to come after the section 1 code or lint gets
  860. X * confused about whether the variables are used
  861. X */
  862. XFILE *yyin = stdin, *yyout = stdout;
  863. X
  864. X/* these variables are all declared out here so that section 3 code can
  865. X * manipulate them
  866. X */
  867. static int yy_start, yy_b_buf_p, yy_c_buf_p, yy_e_buf_p;
  868. static int yy_saw_eof, yy_init = 1;
  869. X
  870. X/* yy_ch_buf has to be 1 character longer than YY_BUF_SIZE, since when
  871. X * setting up yytext we can try to put a '\0' just past the end of the
  872. X * matched text
  873. X */
  874. static char yy_ch_buf[YY_BUF_SIZE + 1];
  875. static int yy_st_buf[YY_BUF_SIZE];
  876. static char yy_hold_char;
  877. char *yytext;
  878. static int yyleng;
  879. X
  880. YY_DECL
  881. X    {
  882. X    int yy_n_chars, yy_lp, yy_iii, yy_buf_pos, yy_act;
  883. X
  884. X%% user's declarations go here
  885. X
  886. X    if ( yy_init )
  887. X    {
  888. X    YY_INIT;
  889. X    yy_start = 1;
  890. X    yy_init = 0;
  891. X    }
  892. X
  893. X    goto get_next_token;
  894. X
  895. do_action:
  896. X    for ( ; ; )
  897. X    {
  898. X    YY_DO_BEFORE_ACTION
  899. X
  900. X#ifdef FLEX_DEBUG
  901. X    fprintf( stderr, "--accepting rule #%d\n", yy_act );
  902. X#endif
  903. X    switch ( yy_act )
  904. X        {
  905. X%% actions go here
  906. X
  907. case YY_NEW_FILE:
  908. break; /* begin reading from new file */
  909. X
  910. case YY_DO_DEFAULT:
  911. YY_DEFAULT_ACTION;
  912. break;
  913. X
  914. case YY_END_TOK:
  915. return ( YY_END_TOK );
  916. X
  917. default:
  918. YY_FATAL_ERROR( "fatal flex scanner internal error" );
  919. X        }
  920. X
  921. get_next_token:
  922. X    {
  923. X    register int yy_curst;
  924. X    register char yy_sym;
  925. X
  926. X    YY_DO_BEFORE_SCAN
  927. X
  928. X    /* set up to begin running DFA */
  929. X
  930. X    yy_curst = yy_start;
  931. X
  932. X    if ( yy_ch_buf[yy_c_buf_p] == '\n' )
  933. X        ++yy_curst;
  934. X
  935. X    /* yy_b_buf_p points to the position in yy_ch_buf
  936. X     * of the start of the current run.
  937. X     */
  938. X
  939. X    yy_b_buf_p = yy_c_buf_p + 1;
  940. X
  941. X    do /* until the machine jams */
  942. X        {
  943. X        if ( yy_c_buf_p == yy_e_buf_p )
  944. X        { /* need more input */
  945. X        if ( yy_e_buf_p >= YY_BUF_LIM )
  946. X            { /* not enough room to do another read */
  947. X            /* see if we can make some room for more chars */
  948. X
  949. X            yy_n_chars = yy_e_buf_p - yy_b_buf_p;
  950. X
  951. X            if ( yy_n_chars >= 0 )
  952. X            /* shift down buffer to make room */
  953. X            for ( yy_iii = 0; yy_iii <= yy_n_chars; ++yy_iii )
  954. X                {
  955. X                yy_buf_pos = yy_b_buf_p + yy_iii;
  956. X                yy_ch_buf[yy_iii] = yy_ch_buf[yy_buf_pos];
  957. X                yy_st_buf[yy_iii] = yy_st_buf[yy_buf_pos];
  958. X                }
  959. X
  960. X            yy_b_buf_p = 0;
  961. X            yy_e_buf_p = yy_n_chars;
  962. X
  963. X            if ( yy_e_buf_p >= YY_BUF_LIM )
  964. X            YY_FATAL_ERROR( "flex input buffer overflowed" );
  965. X
  966. X            yy_c_buf_p = yy_e_buf_p;
  967. X            }
  968. X
  969. X        else if ( yy_saw_eof )
  970. X            {
  971. saweof:            if ( yy_b_buf_p > yy_e_buf_p )
  972. X            {
  973. X            if ( yywrap() )
  974. X                {
  975. X                yy_act = YY_END_TOK;
  976. X                goto do_action;
  977. X                }
  978. X            
  979. X            else
  980. X                {
  981. X                YY_INIT;
  982. X                yy_act = YY_NEW_FILE;
  983. X                goto do_action;
  984. X                }
  985. X            }
  986. X
  987. X            else /* do a jam to eat up more input */
  988. X            {
  989. X#ifndef FLEX_INTERACTIVE_SCANNER
  990. X            /* we're going to decrement yy_c_buf_p upon doing
  991. X             * the jam.  In this case, that's wrong, since
  992. X             * it points to the last non-jam character.  So
  993. X             * we increment it now to counter the decrement.
  994. X             */
  995. X            ++yy_c_buf_p;
  996. X#endif
  997. X            break;
  998. X            }
  999. X            }
  1000. X
  1001. X        YY_INPUT( (yy_ch_buf + yy_c_buf_p + 1), yy_n_chars,
  1002. X              YY_MAX_LINE );
  1003. X
  1004. X        if ( yy_n_chars == YY_NULL )
  1005. X            {
  1006. X            if ( yy_saw_eof )
  1007. X    YY_FATAL_ERROR( "flex scanner saw EOF twice - shouldn't happen" );
  1008. X            yy_saw_eof = 1;
  1009. X            goto saweof;
  1010. X            }
  1011. X
  1012. X        yy_e_buf_p += yy_n_chars;
  1013. X        }
  1014. X
  1015. X        ++yy_c_buf_p;
  1016. X
  1017. X#ifdef FLEX_USE_ECS
  1018. X        yy_sym = e[yy_ch_buf[yy_c_buf_p]];
  1019. X#else
  1020. X        yy_sym = yy_ch_buf[yy_c_buf_p];
  1021. X#endif
  1022. X
  1023. X#ifdef FLEX_FULL_TABLE
  1024. X        yy_curst = n[yy_curst][yy_sym];
  1025. X
  1026. X#else /* get next state from compressed table */
  1027. X
  1028. X        while ( c[b[yy_curst] + yy_sym] != yy_curst )
  1029. X        {
  1030. X        yy_curst = d[yy_curst];
  1031. X
  1032. X#ifdef FLEX_USE_MECS
  1033. X        /* we've arrange it so that templates are never chained
  1034. X         * to one another.  This means we can afford make a
  1035. X         * very simple test to see if we need to convert to
  1036. X         * yy_sym's meta-equivalence class without worrying
  1037. X         * about erroneously looking up the meta-equivalence
  1038. X         * class twice
  1039. X         */
  1040. X
  1041. X        if ( yy_curst >= YY_TEMPLATE )
  1042. X            yy_sym = m[yy_sym];
  1043. X#endif
  1044. X        }
  1045. X
  1046. X        yy_curst = n[b[yy_curst] + yy_sym];
  1047. X
  1048. X#endif
  1049. X
  1050. X        yy_st_buf[yy_c_buf_p] = yy_curst;
  1051. X
  1052. X        }
  1053. X#ifdef FLEX_INTERACTIVE_SCANNER
  1054. X    while ( b[yy_curst] != YY_JAM_BASE );
  1055. X#else
  1056. X    while ( yy_curst != YY_JAM );
  1057. X    --yy_c_buf_p; /* put back character we jammed on */
  1058. X
  1059. X#endif
  1060. X
  1061. X    if ( yy_c_buf_p >= yy_b_buf_p )
  1062. X        { /* we matched some text */
  1063. X        yy_curst = yy_st_buf[yy_c_buf_p];
  1064. X        yy_lp = l[yy_curst];
  1065. X
  1066. X#ifdef FLEX_REJECT_ENABLED
  1067. find_rule: /* we branch to this label when doing a REJECT */
  1068. X#endif
  1069. X
  1070. X        for ( ; ; ) /* until we find what rule we matched */
  1071. X        {
  1072. X#ifdef FLEX_REJECT_ENABLED
  1073. X        if ( yy_lp && yy_lp < l[yy_curst + 1] )
  1074. X            {
  1075. X            yy_act = a[yy_lp];
  1076. X            goto do_action; /* "continue 2" */
  1077. X            }
  1078. X#else
  1079. X        if ( yy_lp )
  1080. X            {
  1081. X            yy_act = yy_lp;
  1082. X            goto do_action; /* "continue 2" */
  1083. X            }
  1084. X#endif
  1085. X
  1086. X        if ( --yy_c_buf_p < yy_b_buf_p )
  1087. X            break;
  1088. X
  1089. X        yy_curst = yy_st_buf[yy_c_buf_p];
  1090. X        yy_lp = l[yy_curst];
  1091. X        }
  1092. X        }
  1093. X
  1094. X    /* if we got this far, then we didn't find any accepting
  1095. X     * states
  1096. X     */
  1097. X
  1098. X    /* so that the default applies to the first char read */
  1099. X    ++yy_c_buf_p;
  1100. X
  1101. X    yy_act = YY_DO_DEFAULT;
  1102. X    }
  1103. X    }
  1104. X
  1105. X    /*NOTREACHED*/
  1106. X    }
  1107. X
  1108. X
  1109. static int unput( c )
  1110. char c;
  1111. X
  1112. X    {
  1113. X    YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */
  1114. X
  1115. X    if ( yy_c_buf_p == 0 )
  1116. X    {
  1117. X    register int i;
  1118. X    register int yy_buf_pos = YY_BUF_MAX;
  1119. X
  1120. X    for ( i = yy_e_buf_p; i >= yy_c_buf_p; --i )
  1121. X        {
  1122. X        yy_ch_buf[yy_buf_pos] = yy_ch_buf[i];
  1123. X        yy_st_buf[yy_buf_pos] = yy_st_buf[i];
  1124. X        --yy_buf_pos;
  1125. X        }
  1126. X
  1127. X    yy_c_buf_p = YY_BUF_MAX - yy_e_buf_p;
  1128. X    yy_e_buf_p = YY_BUF_MAX;
  1129. X    }
  1130. X
  1131. X    if ( yy_c_buf_p <= 0 )
  1132. X    YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1133. X
  1134. X    if ( yy_c_buf_p >= yy_b_buf_p && yy_ch_buf[yy_c_buf_p] == '\n' )
  1135. X    yy_ch_buf[yy_c_buf_p - 1] = '\n';
  1136. X
  1137. X    yy_ch_buf[yy_c_buf_p--] = c;
  1138. X
  1139. X    YY_DO_BEFORE_ACTION; /* set up yytext again */
  1140. X    }
  1141. X
  1142. X
  1143. static int input()
  1144. X
  1145. X    {
  1146. X    int c;
  1147. X
  1148. X    YY_DO_BEFORE_SCAN
  1149. X
  1150. X    if ( yy_c_buf_p == yy_e_buf_p )
  1151. X    { /* need more input */
  1152. X    int yy_n_chars;
  1153. X
  1154. X    /* we can throw away the entire current buffer */
  1155. X    if ( yy_saw_eof )
  1156. X        {
  1157. X        if ( yywrap() )
  1158. X        return ( EOF );
  1159. X
  1160. X        YY_INIT;
  1161. X        }
  1162. X
  1163. X    yy_b_buf_p = 0;
  1164. X    YY_INPUT( yy_ch_buf, yy_n_chars, YY_MAX_LINE );
  1165. X
  1166. X    if ( yy_n_chars == YY_NULL )
  1167. X        {
  1168. X        yy_saw_eof = 1;
  1169. X
  1170. X        if ( yywrap() )
  1171. X        return ( EOF );
  1172. X
  1173. X        YY_INIT;
  1174. X
  1175. X        return ( input() );
  1176. X        }
  1177. X
  1178. X    yy_c_buf_p = -1;
  1179. X    yy_e_buf_p = yy_n_chars - 1;
  1180. X    }
  1181. X
  1182. X    c = yy_ch_buf[++yy_c_buf_p];
  1183. X
  1184. X    YY_DO_BEFORE_ACTION;
  1185. X
  1186. X    return ( c );
  1187. X    }
  1188. END_OF_FILE
  1189. if test 6545 -ne `wc -c <'flex.skel'`; then
  1190.     echo shar: \"'flex.skel'\" unpacked with wrong size!
  1191. fi
  1192. # end of 'flex.skel'
  1193. fi
  1194. if test -f 'flexskelcom.h' -a "${1}" != "-c" ; then 
  1195.   echo shar: Will not clobber existing file \"'flexskelcom.h'\"
  1196. else
  1197. echo shar: Extracting \"'flexskelcom.h'\" \(2400 characters\)
  1198. sed "s/^X//" >'flexskelcom.h' <<'END_OF_FILE'
  1199. X/* common macro definitions for C/FTL programs generated by flex */
  1200. X
  1201. X
  1202. X/* returned upon end-of-file */
  1203. X#define YY_END_TOK 0
  1204. X
  1205. X/* action number for an "end-of-file was seen and yywrap indicated that we
  1206. X * should continue processing"
  1207. X */
  1208. X#define YY_NEW_FILE -1
  1209. X
  1210. X/* action number for "the default action should be done" */
  1211. X#define YY_DO_DEFAULT -2
  1212. X
  1213. X#ifndef BUFSIZ
  1214. X#include <stdio.h>
  1215. X#endif
  1216. X
  1217. X#define YY_BUF_SIZE (BUFSIZ * 2) /* size of input buffer */
  1218. X
  1219. X/* number of characters one rule can match.  One less than YY_BUF_SIZE to make
  1220. X * sure we never access beyond the end of an array
  1221. X */
  1222. X#define YY_BUF_MAX (YY_BUF_SIZE - 1)
  1223. X
  1224. X/* we will never use more than the first YY_BUF_LIM + YY_MAX_LINE positions
  1225. X * of the input buffer
  1226. X */
  1227. X#ifndef YY_MAX_LINE
  1228. X#define YY_MAX_LINE BUFSIZ
  1229. X#endif
  1230. X
  1231. X#define YY_BUF_LIM (YY_BUF_MAX - YY_MAX_LINE)
  1232. X
  1233. X/* copy whatever the last rule matched to the standard output */
  1234. X
  1235. X#define ECHO fputs( yytext, yyout )
  1236. X
  1237. X/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  1238. X * is returned in "result".
  1239. X */
  1240. X#define YY_INPUT(buf,result,max_size) \
  1241. X    if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
  1242. X        YY_FATAL_ERROR( "read() in flex scanner failed" );
  1243. X#define YY_NULL 0
  1244. X
  1245. X/* macro used to output a character */
  1246. X#define YY_OUTPUT(c) putc( c, yyout );
  1247. X
  1248. X/* report a fatal error */
  1249. X#define YY_FATAL_ERROR(msg) \
  1250. X    { \
  1251. X    fputs( msg, stderr ); \
  1252. X    putc( '\n', stderr ); \
  1253. X    exit( 1 ); \
  1254. X    }
  1255. X
  1256. X/* returns the first character of the matched text */
  1257. X#define YY_FIRST_CHAR yy_ch_buf[yy_b_buf_p]
  1258. X
  1259. X/* default yywrap function - always treat EOF as an EOF */
  1260. X#define yywrap() 1
  1261. X
  1262. X/* enter a start condition.  This macro really ought to take a parameter,
  1263. X * but we do it the disgusting crufty way that old Unix-lex does it
  1264. X */
  1265. X#define BEGIN yy_start = 1 +
  1266. X
  1267. X/* callable from YY_INPUT to set things up so that '%' will match.  Proper
  1268. X * usage is "YY_SET_BOL(array,pos)"
  1269. X */
  1270. X#define YY_SET_BOL(array,pos) array[pos - 1] = '\n';
  1271. X
  1272. X/* default declaration of generated scanner - a define so the user can
  1273. X * easily add parameters
  1274. X */
  1275. X#define YY_DECL int yylex()
  1276. X
  1277. X/* return all but the first 'n' matched characters back to the input stream */
  1278. X#define yyless(n) \
  1279. X    { \
  1280. X    YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */ \
  1281. X    yy_c_buf_p = yy_b_buf_p + n - 1; \
  1282. X    YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  1283. X    }
  1284. X
  1285. X/* code executed at the end of each rule */
  1286. X#define YY_BREAK break;
  1287. END_OF_FILE
  1288. if test 2400 -ne `wc -c <'flexskelcom.h'`; then
  1289.     echo shar: \"'flexskelcom.h'\" unpacked with wrong size!
  1290. fi
  1291. # end of 'flexskelcom.h'
  1292. fi
  1293. if test -f 'flexskeldef.h' -a "${1}" != "-c" ; then 
  1294.   echo shar: Will not clobber existing file \"'flexskeldef.h'\"
  1295. else
  1296. echo shar: Extracting \"'flexskeldef.h'\" \(1197 characters\)
  1297. sed "s/^X//" >'flexskeldef.h' <<'END_OF_FILE'
  1298. X/* macro definitions for compressed-table C/FTL programs generated by flex */
  1299. X
  1300. X#include "flexskelcom.h"
  1301. X
  1302. X/* reinitializes everything except the current start condition.  The last
  1303. X * input character is set to a newline so an initial beginning-of-line
  1304. X * rule will match
  1305. X */
  1306. X#define YY_INIT \
  1307. X    { \
  1308. X    yyleng = yy_c_buf_p = yy_e_buf_p = 0; \
  1309. X    yy_hold_char = yy_ch_buf[yy_c_buf_p] = '\n'; \
  1310. X    yytext = &yy_ch_buf[yy_c_buf_p]; \
  1311. X    yy_saw_eof = 0; \
  1312. X    }
  1313. X
  1314. X/* returns the length of the matched text */
  1315. X#define YY_LENG (yy_c_buf_p - yy_b_buf_p + 1)
  1316. X
  1317. X/* done before the next pattern has been matched action */
  1318. X#define YY_DO_BEFORE_SCAN \
  1319. X    yytext[yyleng] = yy_hold_char;
  1320. X
  1321. X/* done after the current pattern has been matched and before the corresponding action */
  1322. X#define YY_DO_BEFORE_ACTION \
  1323. X    yytext = &yy_ch_buf[yy_b_buf_p]; \
  1324. X    yyleng = YY_LENG; \
  1325. X    yy_hold_char = yytext[yyleng]; \
  1326. X    yytext[yyleng] = '\0';
  1327. X
  1328. X/* find the next rule matched */
  1329. X#ifdef FLEX_REJECT_ENABLED
  1330. X#define REJECT \
  1331. X        { \
  1332. X    YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */ \
  1333. X        ++yy_lp; \
  1334. X        goto find_rule; \
  1335. X        }
  1336. X#else
  1337. X#define REJECT YY_FATAL_ERROR( "REJECT used and scanner was not generated using -r" )
  1338. X#endif
  1339. END_OF_FILE
  1340. if test 1197 -ne `wc -c <'flexskeldef.h'`; then
  1341.     echo shar: \"'flexskeldef.h'\" unpacked with wrong size!
  1342. fi
  1343. # end of 'flexskeldef.h'
  1344. fi
  1345. if test -f 'parse.y' -a "${1}" != "-c" ; then 
  1346.   echo shar: Will not clobber existing file \"'parse.y'\"
  1347. else
  1348. echo shar: Extracting \"'parse.y'\" \(8861 characters\)
  1349. sed "s/^X//" >'parse.y' <<'END_OF_FILE'
  1350. X/* parse.y - parser for flex input */
  1351. X
  1352. X/*
  1353. X * Copyright (c) 1987, the University of California
  1354. X * 
  1355. X * The United States Government has rights in this work pursuant to
  1356. X * contract no. DE-AC03-76SF00098 between the United States Department of
  1357. X * Energy and the University of California.
  1358. X * 
  1359. X * This program may be redistributed.  Enhancements and derivative works
  1360. X * may be created provided the new works, if made available to the general
  1361. X * public, are made available for use by anyone.
  1362. X */
  1363. X
  1364. X%token CHAR NUMBER SECTEND SCDECL XSCDECL WHITESPACE NAME PREVCCL
  1365. X
  1366. X%{
  1367. X#include "flexdef.h"
  1368. X
  1369. int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
  1370. int trlcontxt, xcluflg, cclsorted, varlength;
  1371. char clower();
  1372. X
  1373. static int madeany = false;  /* whether we've made the '.' character class */
  1374. X
  1375. X%}
  1376. X
  1377. X%%
  1378. goal            :  initlex sect1 sect1end sect2
  1379. X        ;
  1380. X
  1381. initlex         :
  1382. X            {
  1383. X            /* initialize for processing rules */
  1384. X
  1385. X            /* create default DFA start condition */
  1386. X            scinstal( "INITIAL", false );
  1387. X            }
  1388. X        ;
  1389. X            
  1390. sect1        :  sect1 startconddecl WHITESPACE namelist1 '\n'
  1391. X        |
  1392. X        |  error '\n'
  1393. X            { synerr( "unknown error processing section 1" ); }
  1394. X        ;
  1395. X
  1396. sect1end    :  SECTEND
  1397. X        ;
  1398. X
  1399. startconddecl   :  SCDECL
  1400. X            {
  1401. X            /* these productions are separate from the s1object
  1402. X             * rule because the semantics must be done before
  1403. X             * we parse the remainder of an s1object
  1404. X             */
  1405. X
  1406. X            xcluflg = false;
  1407. X            }
  1408. X        
  1409. X        |  XSCDECL
  1410. X            { xcluflg = true; }
  1411. X        ;
  1412. X
  1413. namelist1    :  namelist1 WHITESPACE NAME
  1414. X            { scinstal( nmstr, xcluflg ); }
  1415. X
  1416. X        |  NAME
  1417. X            { scinstal( nmstr, xcluflg ); }
  1418. X
  1419. X        |  error
  1420. X                        { synerr( "bad start condition list" ); }
  1421. X        ;
  1422. X
  1423. sect2           :  sect2 initforrule flexrule '\n'
  1424. X        |
  1425. X        ;
  1426. X
  1427. initforrule     :
  1428. X            {
  1429. X            /* initialize for a parse of one rule */
  1430. X            trlcontxt = varlength = false;
  1431. X            trailcnt = headcnt = rulelen = 0;
  1432. X            }
  1433. X        ;
  1434. X
  1435. flexrule        :  scon '^' re eol 
  1436. X                        {
  1437. X            pat = link_machines( $3, $4 );
  1438. X            add_accept( pat, headcnt, trailcnt );
  1439. X
  1440. X            for ( i = 1; i <= actvp; ++i )
  1441. X                scbol[actvsc[i]] = mkbranch( scbol[actvsc[i]], pat );
  1442. X            }
  1443. X
  1444. X        |  scon re eol 
  1445. X                        {
  1446. X            pat = link_machines( $2, $3 );
  1447. X            add_accept( pat, headcnt, trailcnt );
  1448. X
  1449. X            for ( i = 1; i <= actvp; ++i )
  1450. X                scset[actvsc[i]] = mkbranch( scset[actvsc[i]], pat );
  1451. X            }
  1452. X
  1453. X                |  '^' re eol 
  1454. X            {
  1455. X            pat = link_machines( $2, $3 );
  1456. X            add_accept( pat, headcnt, trailcnt );
  1457. X
  1458. X            /* add to all non-exclusive start conditions,
  1459. X             * including the default (0) start condition
  1460. X             */
  1461. X
  1462. X            for ( i = 1; i <= lastsc; ++i )
  1463. X                if ( ! scxclu[i] )
  1464. X                scbol[i] = mkbranch( scbol[i], pat );
  1465. X            }
  1466. X
  1467. X                |  re eol 
  1468. X            {
  1469. X            pat = link_machines( $1, $2 );
  1470. X            add_accept( pat, headcnt, trailcnt );
  1471. X
  1472. X            for ( i = 1; i <= lastsc; ++i )
  1473. X                if ( ! scxclu[i] )
  1474. X                scset[i] = mkbranch( scset[i], pat );
  1475. X            }
  1476. X
  1477. X                |  error
  1478. X            { synerr( "unrecognized rule" ); }
  1479. X        ;
  1480. X
  1481. scon            :  '<' namelist2 '>'
  1482. X        ;
  1483. X
  1484. namelist2       :  namelist2 ',' NAME
  1485. X                        {
  1486. X            if ( (scnum = sclookup( nmstr )) == 0 )
  1487. X                synerr( "undeclared start condition" );
  1488. X
  1489. X            else
  1490. X                actvsc[++actvp] = scnum;
  1491. X            }
  1492. X
  1493. X        |  NAME
  1494. X            {
  1495. X            if ( (scnum = sclookup( nmstr )) == 0 )
  1496. X                synerr( "undeclared start condition" );
  1497. X            else
  1498. X                actvsc[actvp = 1] = scnum;
  1499. X            }
  1500. X
  1501. X        |  error
  1502. X            { synerr( "bad start condition list" ); }
  1503. X        ;
  1504. X
  1505. eol             :  '$'
  1506. X                        {
  1507. X            if ( trlcontxt )
  1508. X                {
  1509. X                synerr( "trailing context used twice" );
  1510. X                $$ = mkstate( SYM_EPSILON );
  1511. X                }
  1512. X            else
  1513. X                {
  1514. X                trlcontxt = true;
  1515. X
  1516. X                if ( ! varlength )
  1517. X                headcnt = rulelen;
  1518. X
  1519. X                ++rulelen;
  1520. X                trailcnt = 1;
  1521. X
  1522. X                eps = mkstate( SYM_EPSILON );
  1523. X                $$ = link_machines( eps, mkstate( '\n' ) );
  1524. X                }
  1525. X            }
  1526. X
  1527. X        |
  1528. X                {
  1529. X                $$ = mkstate( SYM_EPSILON );
  1530. X
  1531. X            if ( trlcontxt )
  1532. X                {
  1533. X                if ( varlength && headcnt == 0 )
  1534. X                /* both head and trail are variable-length */
  1535. X                synerr( "illegal trailing context" );
  1536. X
  1537. X                else
  1538. X                trailcnt = rulelen;
  1539. X                }
  1540. X                }
  1541. X        ;
  1542. X
  1543. re              :  re '|' series
  1544. X                        {
  1545. X            varlength = true;
  1546. X
  1547. X            $$ = mkor( $1, $3 );
  1548. X            }
  1549. X
  1550. X        |  re2 series
  1551. X            { $$ = link_machines( $1, $2 ); }
  1552. X
  1553. X        |  series
  1554. X            { $$ = $1; }
  1555. X        ;
  1556. X
  1557. X
  1558. re2        :  re '/'
  1559. X            {
  1560. X            /* this rule is separate from the others for "re" so
  1561. X             * that the reduction will occur before the trailing
  1562. X             * series is parsed
  1563. X             */
  1564. X
  1565. X            if ( trlcontxt )
  1566. X                synerr( "trailing context used twice" );
  1567. X            else
  1568. X                trlcontxt = true;
  1569. X
  1570. X            if ( varlength )
  1571. X                /* the trailing context had better be fixed-length */
  1572. X                varlength = false;
  1573. X            else
  1574. X                headcnt = rulelen;
  1575. X
  1576. X            rulelen = 0;
  1577. X            $$ = $1;
  1578. X            }
  1579. X        ;
  1580. X
  1581. series          :  series singleton
  1582. X                        {
  1583. X            /* this is where concatenation of adjacent patterns
  1584. X             * gets done
  1585. X             */
  1586. X            $$ = link_machines( $1, $2 );
  1587. X            }
  1588. X
  1589. X        |  singleton
  1590. X            { $$ = $1; }
  1591. X        ;
  1592. X
  1593. singleton       :  singleton '*'
  1594. X                        {
  1595. X            varlength = true;
  1596. X
  1597. X            $$ = mkclos( $1 );
  1598. X            }
  1599. X            
  1600. X        |  singleton '+'
  1601. X            {
  1602. X            varlength = true;
  1603. X
  1604. X            $$ = mkposcl( $1 );
  1605. X            }
  1606. X
  1607. X        |  singleton '?'
  1608. X            {
  1609. X            varlength = true;
  1610. X
  1611. X            $$ = mkopt( $1 );
  1612. X            }
  1613. X
  1614. X        |  singleton '{' NUMBER ',' NUMBER '}'
  1615. X            {
  1616. X            varlength = true;
  1617. X
  1618. X            if ( $3 > $5 || $3 <= 0 )
  1619. X                {
  1620. X                synerr( "bad iteration values" );
  1621. X                $$ = $1;
  1622. X                }
  1623. X            else
  1624. X                $$ = mkrep( $1, $3, $5 );
  1625. X            }
  1626. X                
  1627. X        |  singleton '{' NUMBER ',' '}'
  1628. X            {
  1629. X            varlength = true;
  1630. X
  1631. X            if ( $3 <= 0 )
  1632. X                {
  1633. X                synerr( "iteration value must be positive" );
  1634. X                $$ = $1;
  1635. X                }
  1636. X
  1637. X            else
  1638. X                $$ = mkrep( $1, $3, INFINITY );
  1639. X            }
  1640. X
  1641. X        |  singleton '{' NUMBER '}'
  1642. X            {
  1643. X            /* the singleton could be something like "(foo)",
  1644. X             * in which case we have no idea what its length
  1645. X             * is, so we punt here.
  1646. X             */
  1647. X            varlength = true;
  1648. X
  1649. X            if ( $3 <= 0 )
  1650. X                {
  1651. X                synerr( "iteration value must be positive" );
  1652. X                $$ = $1;
  1653. X                }
  1654. X
  1655. X            else
  1656. X                $$ = link_machines( $1, copysingl( $1, $3 - 1 ) );
  1657. X            }
  1658. X
  1659. X        |  '.'
  1660. X            {
  1661. X            if ( ! madeany )
  1662. X                {
  1663. X                /* create the '.' character class */
  1664. X                anyccl = cclinit();
  1665. X                ccladd( anyccl, '\n' );
  1666. X                cclnegate( anyccl );
  1667. X
  1668. X                if ( useecs )
  1669. X                mkeccl( ccltbl + cclmap[anyccl],
  1670. X                    ccllen[anyccl], nextecm,
  1671. X                    ecgroup, CSIZE );
  1672. X                
  1673. X                madeany = true;
  1674. X                }
  1675. X
  1676. X            ++rulelen;
  1677. X
  1678. X            $$ = mkstate( -anyccl );
  1679. X            }
  1680. X
  1681. X        |  fullccl
  1682. X            {
  1683. X            if ( ! cclsorted )
  1684. X                /* sort characters for fast searching.  We use a
  1685. X                 * shell sort since this list could be large.
  1686. X                 */
  1687. X                cshell( ccltbl + cclmap[$1], ccllen[$1] );
  1688. X
  1689. X            if ( useecs )
  1690. X                mkeccl( ccltbl + cclmap[$1], ccllen[$1],
  1691. X                    nextecm, ecgroup, CSIZE );
  1692. X                     
  1693. X            ++rulelen;
  1694. X
  1695. X            $$ = mkstate( -$1 );
  1696. X            }
  1697. X
  1698. X        |  PREVCCL
  1699. X            {
  1700. X            ++rulelen;
  1701. X
  1702. X            $$ = mkstate( -$1 );
  1703. X            }
  1704. X
  1705. X        |  '"' string '"'
  1706. X            { $$ = $2; }
  1707. X
  1708. X        |  '(' re ')'
  1709. X            { $$ = $2; }
  1710. X
  1711. X        |  CHAR
  1712. X            {
  1713. X            ++rulelen;
  1714. X
  1715. X            if ( $1 == '\0' )
  1716. X                synerr( "null in rule" );
  1717. X
  1718. X            if ( caseins && $1 >= 'A' && $1 <= 'Z' )
  1719. X                $1 = clower( $1 );
  1720. X
  1721. X            $$ = mkstate( $1 );
  1722. X            }
  1723. X        ;
  1724. X
  1725. fullccl        :  '[' ccl ']'
  1726. X            { $$ = $2; }
  1727. X
  1728. X        |  '[' '^' ccl ']'
  1729. X            {
  1730. X            /* *Sigh* - to be compatible Unix lex, negated ccls
  1731. X             * match newlines
  1732. X             */
  1733. X#ifdef NOTDEF
  1734. X            ccladd( $3, '\n' ); /* negated ccls don't match '\n' */
  1735. X            cclsorted = false; /* because we added the newline */
  1736. X#endif
  1737. X            cclnegate( $3 );
  1738. X            $$ = $3;
  1739. X            }
  1740. X        ;
  1741. X
  1742. ccl             :  ccl CHAR '-' CHAR
  1743. X                        {
  1744. X            if ( $2 > $4 )
  1745. X                synerr( "negative range in character class" );
  1746. X
  1747. X            else
  1748. X                {
  1749. X                if ( caseins )
  1750. X                {
  1751. X                if ( $2 >= 'A' && $2 <= 'Z' )
  1752. X                    $2 = clower( $2 );
  1753. X                if ( $4 >= 'A' && $4 <= 'Z' )
  1754. X                    $4 = clower( $4 );
  1755. X                }
  1756. X
  1757. X                for ( i = $2; i <= $4; ++i )
  1758. X                    ccladd( $1, i );
  1759. X
  1760. X                /* keep track if this ccl is staying in alphabetical
  1761. X                 * order
  1762. X                 */
  1763. X                cclsorted = cclsorted && ($2 > lastchar);
  1764. X                lastchar = $4;
  1765. X                }
  1766. X            
  1767. X            $$ = $1;
  1768. X            }
  1769. X
  1770. X        |  ccl CHAR
  1771. X                {
  1772. X            if ( caseins )
  1773. X                if ( $2 >= 'A' && $2 <= 'Z' )
  1774. X                $2 = clower( $2 );
  1775. X
  1776. X            ccladd( $1, $2 );
  1777. X            cclsorted = cclsorted && ($2 > lastchar);
  1778. X            lastchar = $2;
  1779. X            $$ = $1;
  1780. X            }
  1781. X
  1782. X        |
  1783. X            {
  1784. X            cclsorted = true;
  1785. X            lastchar = 0;
  1786. X            $$ = cclinit();
  1787. X            }
  1788. X        ;
  1789. X
  1790. string        :  string CHAR
  1791. X                        {
  1792. X            if ( caseins )
  1793. X                if ( $2 >= 'A' && $2 <= 'Z' )
  1794. X                $2 = clower( $2 );
  1795. X
  1796. X            ++rulelen;
  1797. X
  1798. X            $$ = link_machines( $1, mkstate( $2 ) );
  1799. X            }
  1800. X
  1801. X        |
  1802. X            { $$ = mkstate( SYM_EPSILON ); }
  1803. X        ;
  1804. X
  1805. X%%
  1806. X
  1807. X/* synerr - report a syntax error
  1808. X *
  1809. X * synopsis
  1810. X *    char str[];
  1811. X *    synerr( str );
  1812. X */
  1813. X
  1814. synerr( str )
  1815. char str[];
  1816. X
  1817. X    {
  1818. X    syntaxerror = true;
  1819. X    fprintf( stderr, "Syntax error at line %d:  %s\n", linenum, str );
  1820. X    }
  1821. X
  1822. X
  1823. X/* yyerror - eat up an error message from the parser
  1824. X *
  1825. X * synopsis
  1826. X *    char msg[];
  1827. X *    yyerror( msg );
  1828. X */
  1829. X
  1830. yyerror( msg )
  1831. char msg[];
  1832. X
  1833. X    {
  1834. X    }
  1835. END_OF_FILE
  1836. if test 8861 -ne `wc -c <'parse.y'`; then
  1837.     echo shar: \"'parse.y'\" unpacked with wrong size!
  1838. fi
  1839. # end of 'parse.y'
  1840. fi
  1841. if test -f 'sym.c' -a "${1}" != "-c" ; then 
  1842.   echo shar: Will not clobber existing file \"'sym.c'\"
  1843. else
  1844. echo shar: Extracting \"'sym.c'\" \(6087 characters\)
  1845. sed "s/^X//" >'sym.c' <<'END_OF_FILE'
  1846. X/* sym - symbol table routines */
  1847. X
  1848. X/*
  1849. X * Copyright (c) 1987, the University of California
  1850. X * 
  1851. X * The United States Government has rights in this work pursuant to
  1852. X * contract no. DE-AC03-76SF00098 between the United States Department of
  1853. X * Energy and the University of California.
  1854. X * 
  1855. X * This program may be redistributed.  Enhancements and derivative works
  1856. X * may be created provided the new works, if made available to the general
  1857. X * public, are made available for use by anyone.
  1858. X */
  1859. X
  1860. X#include "flexdef.h"
  1861. X
  1862. struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
  1863. struct hash_entry *sctbl[START_COND_HASH_SIZE];
  1864. struct hash_entry *ccltab[CCL_HASH_SIZE];
  1865. X
  1866. struct hash_entry *findsym();
  1867. X
  1868. X
  1869. X/* addsym - add symbol and definitions to symbol table
  1870. X *
  1871. X * synopsis
  1872. X *    char sym[], *str_def;
  1873. X *    int int_def;
  1874. X *    hash_table table;
  1875. X *    int table_size;
  1876. X *    0 / -1 = addsym( sym, def, int_def, table, table_size );
  1877. X *
  1878. X * -1 is returned if the symbol already exists, and the change not made.
  1879. X */
  1880. X
  1881. int addsym( sym, str_def, int_def, table, table_size )
  1882. register char sym[];
  1883. char *str_def;
  1884. int int_def;
  1885. hash_table table;
  1886. int table_size;
  1887. X
  1888. X    {
  1889. X    int hash_val = hashfunct( sym, table_size );
  1890. X    register struct hash_entry *entry = table[hash_val];
  1891. X    register struct hash_entry *new_entry;
  1892. X    register struct hash_entry *successor;
  1893. X    char *malloc();
  1894. X
  1895. X    while ( entry )
  1896. X    {
  1897. X    if ( ! strcmp( sym, entry->name ) )
  1898. X        { /* entry already exists */
  1899. X        return ( -1 );
  1900. X        }
  1901. X    
  1902. X    entry = entry->next;
  1903. X    }
  1904. X
  1905. X    /* create new entry */
  1906. X    new_entry = (struct hash_entry *) malloc( sizeof( struct hash_entry ) );
  1907. X
  1908. X    if ( new_entry == NULL )
  1909. X    flexfatal( "symbol table memory allocation failed" );
  1910. X
  1911. X    if ( (successor = table[hash_val]) )
  1912. X    {
  1913. X    new_entry->next = successor;
  1914. X    successor->prev = new_entry;
  1915. X    }
  1916. X    else
  1917. X    new_entry->next = NULL;
  1918. X
  1919. X    new_entry->prev = NULL;
  1920. X    new_entry->name = sym;
  1921. X    new_entry->str_val = str_def;
  1922. X    new_entry->int_val = int_def;
  1923. X
  1924. X    table[hash_val] = new_entry;
  1925. X
  1926. X    return ( 0 );
  1927. X    }
  1928. X
  1929. X
  1930. X/* cclinstal - save the text of a character class
  1931. X *
  1932. X * synopsis
  1933. X *    char ccltxt[];
  1934. X *    int cclnum;
  1935. X *    cclinstal( ccltxt, cclnum );
  1936. X */
  1937. X
  1938. cclinstal( ccltxt, cclnum )
  1939. char ccltxt[];
  1940. int cclnum;
  1941. X
  1942. X    {
  1943. X    /* we don't bother checking the return status because we are not called
  1944. X     * unless the symbol is new
  1945. X     */
  1946. X    char *copy_string();
  1947. X
  1948. X    (void) addsym( copy_string( ccltxt ), (char *) 0, cclnum,
  1949. X           ccltab, CCL_HASH_SIZE );
  1950. X    }
  1951. X
  1952. X
  1953. X/* ccllookup - lookup the number associated with character class text
  1954. X *
  1955. X * synopsis
  1956. X *    char ccltxt[];
  1957. X *    int ccllookup, cclval;
  1958. X *    cclval/0 = ccllookup( ccltxt );
  1959. X */
  1960. X
  1961. int ccllookup( ccltxt )
  1962. char ccltxt[];
  1963. X
  1964. X    {
  1965. X    return ( findsym( ccltxt, ccltab, CCL_HASH_SIZE )->int_val );
  1966. X    }
  1967. X
  1968. X
  1969. X/* findsym - find symbol in symbol table
  1970. X *
  1971. X * synopsis
  1972. X *    char sym[];
  1973. X *    hash_table table;
  1974. X *    int table_size;
  1975. X *    struct hash_entry *entry, *findsym();
  1976. X *    entry = findsym( sym, table, table_size );
  1977. X */
  1978. X
  1979. struct hash_entry *findsym( sym, table, table_size )
  1980. register char sym[];
  1981. hash_table table;
  1982. int table_size;
  1983. X
  1984. X    {
  1985. X    register struct hash_entry *entry = table[hashfunct( sym, table_size )];
  1986. X    static struct hash_entry empty_entry =
  1987. X    {
  1988. X    (struct hash_entry *) 0, (struct hash_entry *) 0, NULL, NULL, 0,
  1989. X    } ;
  1990. X
  1991. X    while ( entry )
  1992. X    {
  1993. X    if ( ! strcmp( sym, entry->name ) )
  1994. X        return ( entry );
  1995. X    entry = entry->next;
  1996. X    }
  1997. X
  1998. X    return ( &empty_entry );
  1999. X    }
  2000. X
  2001. X    
  2002. X/* hashfunct - compute the hash value for "str" and hash size "hash_size"
  2003. X *
  2004. X * synopsis
  2005. X *    char str[];
  2006. X *    int hash_size, hash_val;
  2007. X *    hash_val = hashfunct( str, hash_size );
  2008. X */
  2009. X
  2010. int hashfunct( str, hash_size )
  2011. register char str[];
  2012. int hash_size;
  2013. X
  2014. X    {
  2015. X    register int hashval;
  2016. X    register int locstr;
  2017. X
  2018. X    hashval = 0;
  2019. X    locstr = 0;
  2020. X
  2021. X    while ( str[locstr] )
  2022. X    hashval = ((hashval << 1) + str[locstr++]) % hash_size;
  2023. X
  2024. X    return ( hashval );
  2025. X    }
  2026. X
  2027. X
  2028. X/* ndinstal - install a name definition
  2029. X *
  2030. X * synopsis
  2031. X *    char nd[], def[];
  2032. X *    ndinstal( nd, def );
  2033. X */
  2034. X
  2035. ndinstal( nd, def )
  2036. char nd[], def[];
  2037. X
  2038. X    {
  2039. X    char *copy_string();
  2040. X
  2041. X    if ( addsym( copy_string( nd ), copy_string( def ), 0,
  2042. X         ndtbl, NAME_TABLE_HASH_SIZE ) )
  2043. X    synerr( "name defined twice" );
  2044. X    }
  2045. X
  2046. X
  2047. X/* ndlookup - lookup a name definition
  2048. X *
  2049. X * synopsis
  2050. X *    char nd[], *def;
  2051. X *    char *ndlookup();
  2052. X *    def/NULL = ndlookup( nd );
  2053. X */
  2054. X
  2055. char *ndlookup( nd )
  2056. char nd[];
  2057. X
  2058. X    {
  2059. X    return ( findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val );
  2060. X    }
  2061. X
  2062. X
  2063. X/* scinstal - make a start condition
  2064. X *
  2065. X * synopsis
  2066. X *    char str[];
  2067. X *    int xcluflg;
  2068. X *    scinstal( str, xcluflg );
  2069. X *
  2070. X * NOTE
  2071. X *    the start condition is Exclusive if xcluflg is true
  2072. X */
  2073. X
  2074. scinstal( str, xcluflg )
  2075. char str[];
  2076. int xcluflg;
  2077. X
  2078. X    {
  2079. X    char *copy_string();
  2080. X
  2081. X    /* bit of a hack.  We know how the default start-condition is
  2082. X     * declared, and don't put out a define for it, because it
  2083. X     * would come out as "#define 0 1"
  2084. X     */
  2085. X    /* actually, this is no longer the case.  The default start-condition
  2086. X     * is now called "INITIAL".  But we keep the following for the sake
  2087. X     * of future robustness.
  2088. X     */
  2089. X
  2090. X    if ( strcmp( str, "0" ) )
  2091. X    printf( "#define %s %d\n", str, lastsc * 2 );
  2092. X
  2093. X    if ( ++lastsc >= current_max_scs )
  2094. X    {
  2095. X    current_max_scs += MAX_SCS_INCREMENT;
  2096. X
  2097. X    ++num_reallocs;
  2098. X
  2099. X    scset = reallocate_integer_array( scset, current_max_scs );
  2100. X    scbol = reallocate_integer_array( scbol, current_max_scs );
  2101. X    scxclu = reallocate_integer_array( scxclu, current_max_scs );
  2102. X    actvsc = reallocate_integer_array( actvsc, current_max_scs );
  2103. X    }
  2104. X
  2105. X    if ( addsym( copy_string( str ), (char *) 0, lastsc,
  2106. X     sctbl, START_COND_HASH_SIZE ) )
  2107. X    lerrsf( "start condition %s declared twice", str );
  2108. X
  2109. X    scset[lastsc] = mkstate( SYM_EPSILON );
  2110. X    scbol[lastsc] = mkstate( SYM_EPSILON );
  2111. X    scxclu[lastsc] = xcluflg;
  2112. X    }
  2113. X
  2114. X
  2115. X/* sclookup - lookup the number associated with a start condition
  2116. X *
  2117. X * synopsis
  2118. X *    char str[], scnum;
  2119. X *    int sclookup;
  2120. X *    scnum/0 = sclookup( str );
  2121. X */
  2122. X
  2123. int sclookup( str )
  2124. char str[];
  2125. X
  2126. X    {
  2127. X    return ( findsym( str, sctbl, START_COND_HASH_SIZE )->int_val );
  2128. X    }
  2129. END_OF_FILE
  2130. if test 6087 -ne `wc -c <'sym.c'`; then
  2131.     echo shar: \"'sym.c'\" unpacked with wrong size!
  2132. fi
  2133. # end of 'sym.c'
  2134. fi
  2135. if test -f 'yylex.c' -a "${1}" != "-c" ; then 
  2136.   echo shar: Will not clobber existing file \"'yylex.c'\"
  2137. else
  2138. echo shar: Extracting \"'yylex.c'\" \(3554 characters\)
  2139. sed "s/^X//" >'yylex.c' <<'END_OF_FILE'
  2140. X/* yylex - scanner front-end for flex */
  2141. X
  2142. X#include "flexdef.h"
  2143. X#include "parse.h"
  2144. X
  2145. X/*
  2146. X * Copyright (c) 1987, the University of California
  2147. X * 
  2148. X * The United States Government has rights in this work pursuant to
  2149. X * contract no. DE-AC03-76SF00098 between the United States Department of
  2150. X * Energy and the University of California.
  2151. X * 
  2152. X * This program may be redistributed.  Enhancements and derivative works
  2153. X * may be created provided the new works, if made available to the general
  2154. X * public, are made available for use by anyone.
  2155. X */
  2156. X
  2157. X/* yylex - scan for a regular expression token
  2158. X *
  2159. X * synopsis
  2160. X *
  2161. X *   token = yylex();
  2162. X *
  2163. X *     token - return token found
  2164. X */
  2165. X
  2166. int yylex()
  2167. X
  2168. X    {
  2169. X    int toktype;
  2170. X    static int beglin = false;
  2171. X
  2172. X    if ( eofseen )
  2173. X    toktype = EOF;
  2174. X    else
  2175. X    toktype = flexscan();
  2176. X
  2177. X    if ( toktype == EOF )
  2178. X    {
  2179. X    eofseen = 1;
  2180. X
  2181. X    if ( sectnum == 1 )
  2182. X        {
  2183. X        synerr( "unexpected EOF" );
  2184. X        sectnum = 2;
  2185. X        toktype = SECTEND;
  2186. X        }
  2187. X
  2188. X    else if ( sectnum == 2 )
  2189. X        {
  2190. X        sectnum = 3;
  2191. X        toktype = SECTEND;
  2192. X        }
  2193. X
  2194. X    else
  2195. X        toktype = 0;
  2196. X    }
  2197. X
  2198. X    if ( trace )
  2199. X    {
  2200. X    if ( beglin )
  2201. X        {
  2202. X        fprintf( stderr, "%d\t", accnum + 1 );
  2203. X        beglin = 0;
  2204. X        }
  2205. X
  2206. X    switch ( toktype )
  2207. X        {
  2208. X        case '<':
  2209. X        case '>':
  2210. X        case '^':
  2211. X        case '$':
  2212. X        case '"':
  2213. X        case '[':
  2214. X        case ']':
  2215. X        case '{':
  2216. X        case '}':
  2217. X        case '|':
  2218. X        case '(':
  2219. X        case ')':
  2220. X        case '-':
  2221. X        case '/':
  2222. X        case '\\':
  2223. X        case '?':
  2224. X        case '.':
  2225. X        case '*':
  2226. X        case '+':
  2227. X        case ',':
  2228. X        (void) putc( toktype, stderr );
  2229. X        break;
  2230. X
  2231. X        case '\n':
  2232. X        (void) putc( '\n', stderr );
  2233. X
  2234. X        if ( sectnum == 2 )
  2235. X            beglin = 1;
  2236. X
  2237. X        break;
  2238. X
  2239. X        case SCDECL:
  2240. X        fputs( "%s", stderr );
  2241. X        break;
  2242. X
  2243. X        case XSCDECL:
  2244. X        fputs( "%x", stderr );
  2245. X        break;
  2246. X
  2247. X        case WHITESPACE:
  2248. X        (void) putc( ' ', stderr );
  2249. X        break;
  2250. X
  2251. X        case SECTEND:
  2252. X        fputs( "%%\n", stderr );
  2253. X
  2254. X        /* we set beglin to be true so we'll start
  2255. X         * writing out numbers as we echo rules.  flexscan() has
  2256. X         * already assigned sectnum
  2257. X         */
  2258. X
  2259. X        if ( sectnum == 2 )
  2260. X            beglin = 1;
  2261. X
  2262. X        break;
  2263. X
  2264. X        case NAME:
  2265. X        fprintf( stderr, "'%s'", nmstr );
  2266. X        break;
  2267. X
  2268. X        case CHAR:
  2269. X        switch ( yylval )
  2270. X            {
  2271. X            case '<':
  2272. X            case '>':
  2273. X            case '^':
  2274. X            case '$':
  2275. X            case '"':
  2276. X            case '[':
  2277. X            case ']':
  2278. X            case '{':
  2279. X            case '}':
  2280. X            case '|':
  2281. X            case '(':
  2282. X            case ')':
  2283. X            case '-':
  2284. X            case '/':
  2285. X            case '\\':
  2286. X            case '?':
  2287. X            case '.':
  2288. X            case '*':
  2289. X            case '+':
  2290. X            case ',':
  2291. X            fprintf( stderr, "\\%c", yylval );
  2292. X            break;
  2293. X
  2294. X            case 1:
  2295. X            case 2:
  2296. X            case 3:
  2297. X            case 4:
  2298. X            case 5:
  2299. X            case 6:
  2300. X            case 7:
  2301. X            case 8:
  2302. X            case 9:
  2303. X            case 10:
  2304. X            case 11:
  2305. X            case 12:
  2306. X            case 13:
  2307. X            case 14:
  2308. X            case 15:
  2309. X            case 16:
  2310. X            case 17:
  2311. X            case 18:
  2312. X            case 19:
  2313. X            case 20:
  2314. X            case 21:
  2315. X            case 22:
  2316. X            case 23:
  2317. X            case 24:
  2318. X            case 25:
  2319. X            case 26:
  2320. X            case 27:
  2321. X            case 28:
  2322. X            case 29:
  2323. X            case 30:
  2324. X            case 31:
  2325. X            fprintf( stderr, "^%c", 'A' + yylval - 1 );
  2326. X            break;
  2327. X
  2328. X            case 127:
  2329. X            (void) putc( '^', stderr );
  2330. X            (void) putc( '@', stderr );
  2331. X            break;
  2332. X
  2333. X            default:
  2334. X            (void) putc( yylval, stderr );
  2335. X            break;
  2336. X            }
  2337. X            
  2338. X        break;
  2339. X
  2340. X        case NUMBER:
  2341. X        fprintf( stderr, "%d", yylval );
  2342. X        break;
  2343. X
  2344. X        case PREVCCL:
  2345. X        fprintf( stderr, "[%d]", yylval );
  2346. X        break;
  2347. X
  2348. X        case 0:
  2349. X        fprintf( stderr, "End Marker" );
  2350. X        break;
  2351. X
  2352. X        default:
  2353. X        fprintf( stderr, "*Something Weird* - tok: %d val: %d\n",
  2354. X             toktype, yylval );
  2355. X        break;
  2356. X        }
  2357. X    }
  2358. X        
  2359. X    return ( toktype );
  2360. X    }
  2361. END_OF_FILE
  2362. if test 3554 -ne `wc -c <'yylex.c'`; then
  2363.     echo shar: \"'yylex.c'\" unpacked with wrong size!
  2364. fi
  2365. # end of 'yylex.c'
  2366. fi
  2367. echo shar: End of archive 1 \(of 5\).
  2368. cp /dev/null ark1isdone
  2369. MISSING=""
  2370. for I in 1 2 3 4 5 ; do
  2371.     if test ! -f ark${I}isdone ; then
  2372.     MISSING="${MISSING} ${I}"
  2373.     fi
  2374. done
  2375. if test "${MISSING}" = "" ; then
  2376.     echo You have unpacked all 5 archives.
  2377.     rm -f ark[1-9]isdone
  2378. else
  2379.     echo You still need to unpack the following archives:
  2380.     echo "        " ${MISSING}
  2381. fi
  2382. ##  End of shell archive.
  2383. exit 0
  2384.